/**
 * 
 */
package in.smartbillpay.web.services;
import in.smartbillpay.web.dao.LocationDao;
import in.smartbillpay.web.models.City;
import in.smartbillpay.web.models.District;
import in.smartbillpay.web.models.State;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ADIMBLE
 *
 */
@Service
@Transactional(readOnly = true)
public class LocationServiceImpl implements LocationService {
	@Autowired
	private LocationDao locationDao;

	
	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getCityById(int)
	 */
	public City getCityById(int id) {
		return locationDao.getCityById(id);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getDistrictById(int)
	 */
	public District getDistrictById(int id) {
		return locationDao.getDistrictById(id);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getStateById(int)
	 */
	public State getStateById(int id) {
		return locationDao.getStateById(id);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getAllCities()
	 */
	public List<City> getAllCities() {
		return locationDao.getAllCities();
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getAllDistricts()
	 */
	public List<District> getAllDistricts() {
		return locationDao.getAllDistricts();
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#getAllState()
	 */
	public List<State> getAllState() {
		return locationDao.getAllState();
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#saveOrUpdate(in.smartbillpay.web.models.City)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public City saveOrUpdate(City city) {
		return locationDao.saveOrUpdate(city);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#saveOrUpdate(in.smartbillpay.web.models.District)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public District saveOrUpdate(District district) {
		return locationDao.saveOrUpdate(district);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#saveOrUpdate(in.smartbillpay.web.models.State)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public State saveOrUpdate(State state) {
		return locationDao.saveOrUpdate(state);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#delete(in.smartbillpay.web.models.City)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public void delete(City city) {
		locationDao.delete(city);
	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#delete(in.smartbillpay.web.models.District)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public void delete(District district) {
		locationDao.delete(district);	}

	/* (non-Javadoc)
	 * @see in.smartbillpay.web.services.LocationService#delete(in.smartbillpay.web.models.State)
	 */
	@Transactional(readOnly = false, propagation = Propagation.NESTED)
	public void delete(State state) {
		locationDao.delete(state);
	}

	/**
	 * @return the locationDao
	 */
	public LocationDao getLocationDao() {
		return locationDao;
	}

	/**
	 * @param locationDao the locationDao to set
	 */
	public void setLocationDao(LocationDao locationDao) {
		this.locationDao = locationDao;
	}

	public void deleteState(int id) {
		getLocationDao().delete(getLocationDao().getStateById(id));
		
	}
	public void deleteDistrict(int id) {
		getLocationDao().delete(getLocationDao().getDistrictById(id));
		
	}

	public List<City> getCities(int districtId) {
		return getLocationDao().getCities(districtId);
	}

	public List<District> getDistricts(int stateId) {
		return getLocationDao().getDistricts(stateId);
	}

	public void deleteCity(int id) {
		getLocationDao().delete(getLocationDao().getCityById(id));
		
	}

}
